<template>
  <transition name="el-zoom-in-center">
    <div class="JNPF-preview-main">
      <div class="JNPF-common-page-header">
        <el-page-header @back="goBack"
                        :content="!dataForm.id ? '新建':'上传报告'"/>
        <div class="options">
          <el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading" :disabled='continueBtnLoading'> 保 存
          </el-button>
          <el-button @click="goBack"> 取 消</el-button>
        </div>
      </div>
      <el-row :gutter="60" class="main" :style="{margin: '0 auto',width: '100%'}">
        <el-form ref="formRef" :model="dataForm" :rules="dataRule" size="medium" label-width="100px"
                 label-position="top">
          <template v-if="!loading">
            <!-- 具体表单 -->
            <el-col :span="4">
              <el-row :gutter="30">
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfText
                      :textStyle='{"color":"#000000","font-weight":"normal","text-decoration":"none","font-size":12,"line-height":32,"font-style":"normal","text-align":"left"}'>
                    </JnpfText>
                  </jnpf-form-tip-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="16" class="project-main">
              <el-row :gutter="30">
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfText
                      :textStyle='{"color":"#1684FC","font-weight":"bold","text-decoration":"none","font-size":24,"line-height":32,"font-style":"normal","text-align":"center"}'
                      content="数字化改造验收">
                    </JnpfText>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="12">
                  <jnpf-form-tip-item
                    label="企业名称" prop="enterpriseName">
                    <JnpfInput v-model="dataForm.enterpriseName" @change="changeData('enterpriseName',-1)"
                               placeholder="自动填充不可修改" readonly clearable :style='{"width":"100%"}'>
                    </JnpfInput>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="12">
                  <jnpf-form-tip-item
                    label="企业信用代码" label-width="125px" prop="enterpriseCreditCode">
                    <JnpfInput v-model="dataForm.enterpriseCreditCode" @change="changeData('enterpriseCreditCode',-1)"
                               placeholder="自动填充不可修改" readonly clearable :style='{"width":"100%"}'>
                    </JnpfInput>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="项目名称" prop="projectNames">
                    <JnpfTextarea v-model="dataForm.projectNames" @change="changeData('projectNames',-1)"
                                  placeholder="自动填充不可修改" readonly :style='{"width":"100%"}' true type="textarea"
                                  :autosize='{"minRows":4,"maxRows":4}'>
                    </JnpfTextarea>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item label="数字化改造产品或服务预算信息" >
                    <el-table :data="projectDigitalBudgetList" border>
                      <el-table-column prop="F_Project_Name" label="项目名称" align="center"></el-table-column>
                      <el-table-column prop="digitalBudget" label="数字化改造产品或服务预算" align="center">
                        <el-table-column prop="F_Budget_Name" label="预算名称" align="center">
                          <template slot-scope="scope">
                            <div v-for="item in scope.row.digitalBudget">{{item.F_Budget_Name}}</div>
                          </template>
                        </el-table-column>
                        <el-table-column prop="F_Budget_Money" label="预算金额(万元)" align="center">
                          <template slot-scope="scope">
                            <div v-for="item in scope.row.digitalBudget">{{item.F_Budget_Money}}</div>
                          </template>
                        </el-table-column>
                      </el-table-column>
                    </el-table>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item label="其他支出预算" >
                    <el-table :data="otherProjectDigitalBudgetList" border>
                      <el-table-column prop="F_Project_Name" label="项目名称" align="center"></el-table-column>
                      <el-table-column prop="otherDigitalBudget" label="其他支出预算" align="center">
                        <el-table-column prop="F_Budget_Name" label="预算名称" align="center">
                          <template slot-scope="scope">
                            <div v-for="item in scope.row.otherDigitalBudget">{{item.F_Budget_Name}}</div>
                          </template>
                        </el-table-column>
                        <el-table-column prop="F_Budget_Money" label="预算金额(万元)" align="center">
                          <template slot-scope="scope">
                            <div v-for="item in scope.row.otherDigitalBudget">{{item.F_Budget_Money}}</div>
                          </template>
                        </el-table-column>
                      </el-table-column>
                    </el-table>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item label="数字化改造项目服务合同（盖章扫描版） "
                                      prop="digitalProjectContract">
                    <div v-for="item in dataForm.digitalProjectContract" class="file-main">
                      <label>{{ item.projectName }} ：</label>
                      <JnpfUploadFile v-model="item.projectFiles"
                                      disabled
                                      detailed :fileSize="10" sizeUnit="MB" :limit="9" pathType="defaultPath"
                                      :isAccount="0" buttonText="点击上传">
                      </JnpfUploadFile>
                    </div>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item label="数字化改造项目方案（盖章扫描版）"
                                      prop="digitalProjectPlan">
                    <div v-for="item in dataForm.digitalProjectPlan" class="file-main">
                      <label>{{ item.projectName }} ：</label>
                      <JnpfUploadFile v-model="item.projectFiles"
                                      disabled
                                      detailed :fileSize="10" sizeUnit="MB" :limit="9" pathType="defaultPath"
                                      :isAccount="0" buttonText="点击上传">
                      </JnpfUploadFile>
                    </div>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="项目投资发票和付款凭证等交易记录（扫描版）" prop="transactionRecords">
                    <JnpfUploadFile v-model="dataForm.transactionRecords" @change="changeData('transactionRecords',-1)"
                                    disabled tipText="请上传pdf格式，如有多项材料，请压缩至一个文件夹上传" accept=".pdf" :fileSize="200"
                                    sizeUnit="MB" :limit="1" pathType="defaultPath" :isAccount="0" buttonText="点击上传">
                    </JnpfUploadFile>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="《福州市中小企业数字化转型被改造试点企业项目验收申请函》（盖章扫描版，详见附件)" prop="scanningCopy">
                    <JnpfUploadFile v-model="dataForm.scanningCopy" @change="changeData('scanningCopy',-1)"
                                    disabled tipText="请上传pdf格式" accept=".pdf" :fileSize="200" sizeUnit="MB" :limit="2"
                                    pathType="defaultPath" :isAccount="0" buttonText="点击上传">
                    </JnpfUploadFile>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfDivider
                      contentPosition="center">
                    </JnpfDivider>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="验收结果建议" prop="acceptIspass">
                    <JnpfRadio v-model="dataForm.acceptIspass" @change="changeData('acceptIspass',-1)"
                               optionType="default" direction="horizontal" size="small" :options="acceptIspassOptions"
                               :props="acceptIspassProps">
                    </JnpfRadio>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24" v-if="dataForm.acceptIspass==='0'">
                  <jnpf-form-tip-item
                    label="提供整改意见" prop="rectificationOpinions">
                    <JnpfTextarea v-model="dataForm.rectificationOpinions"
                                  @change="changeData('rectificationOpinions',-1)"
                                  placeholder="请输入" :style='{"width":"100%"}' true type="textarea"
                                  :autosize='{"minRows":4,"maxRows":4}'>
                    </JnpfTextarea>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="12" v-if="dataForm.acceptIspass==='1'">
                  <jnpf-form-tip-item
                    label="改造后数字化水平等级 " prop="digitizationLevel">
                    <JnpfSelect v-model="dataForm.digitizationLevel" @change="changeData('digitizationLevel',-1)"
                                placeholder="请选择" clearable :style='{"width":"100%"}'
                                :options="digitizationLevelOptions" :props="digitizationLevelProps">
                    </JnpfSelect>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24" v-if="dataForm.acceptIspass==='1'">
                  <jnpf-form-tip-item
                    label="企业数字化改造项目成效验收报告 " prop="performanceAcceptanceReport">
                    <JnpfUploadFile v-model="dataForm.performanceAcceptanceReport"
                                    @change="changeData('performanceAcceptanceReport',-1)"
                                    tipText="如有多项材料，请压缩至一个文件夹上传 " :fileSize="50" sizeUnit="MB" :limit="1"
                                    pathType="defaultPath" :isAccount="0" buttonText="点击上传">
                    </JnpfUploadFile>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24" v-if="dataForm.acceptIspass==='1'">
                  <jnpf-form-tip-item
                    label="企业数字化水平评测报告 " prop="digitalEvaluationReport">
                    <JnpfUploadFile v-model="dataForm.digitalEvaluationReport"
                                    @change="changeData('digitalEvaluationReport',-1)"
                                    tipText="如有多项材料，请压缩至一个文件夹上传 " :fileSize="50" sizeUnit="MB" :limit="1"
                                    pathType="defaultPath" :isAccount="0" buttonText="点击上传">
                    </JnpfUploadFile>
                  </jnpf-form-tip-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="4">
              <el-row :gutter="30">
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfText
                      :textStyle='{"color":"#000000","font-weight":"normal","text-decoration":"none","font-size":12,"line-height":32,"font-style":"normal","text-align":"left"}'>
                    </JnpfText>
                  </jnpf-form-tip-item>
                </el-col>
              </el-row>
            </el-col>
            <!-- 表单结束 -->
          </template>
        </el-form>
        <SelectDialog v-if="selectDialogVisible" :config="currTableConf" :formData="dataForm"
                      ref="selectDialog" @select="addForSelect" @close="selectDialogVisible=false"/>
      </el-row>
    </div>
  </transition>
</template>


<script>
import request from '@/utils/request'
import {mapGetters} from "vuex";
import {getDataInterfaceRes} from '@/api/systemData/dataInterface'
import {getDictionaryDataSelector} from '@/api/systemData/dictionary'
import {getDefaultCurrentValueUserId} from '@/api/permission/user'
import {getDefaultCurrentValueDepartmentId} from '@/api/permission/organize'
import {
  getDateDay,
  getLaterData,
  getBeforeData,
  getBeforeTime,
  getLaterTime
} from '@/components/Generator/utils/index.js'
import {thousandsFormat} from "@/components/Generator/utils/index"
import axios from "axios";

export default {
  components: {},
  props: [],
  data() {
    return {
      projectDigitalBudgetList: [],
      otherProjectDigitalBudgetList: [],
      dataFormSubmitType: 0,
      continueBtnLoading: false,
      index: 0,
      prevDis: false,
      nextDis: false,
      allList: [],
      visible: false,
      loading: false,
      btnLoading: false,
      formRef: 'formRef',
      setting: {},
      eventType: '',
      userBoxVisible: false,
      selectDialogVisible: false,
      currTableConf: {},
      dataValueAll: {},
      addTableConf: {},
      //可选范围默认值
      ableAll: {},
      tableRows: {},
      Vmodel: "",
      currVmodel: "",
      dataForm: {
        enterpriseName: undefined,
        enterpriseCreditCode: undefined,
        county: undefined,
        phone: undefined,
        projectId: undefined,
        projectNames: undefined,
        digitalProjectContract: [],
        digitalProjectPlan: [],
        transactionRecords: [],
        scanningCopy: [{
          "fileSize": 13824,
          "fileExtension": "docx",
          "name": "福州市中小企业数字化转型被改造试点企业项目验收申请函模板.docx",
          "url": "/api/file/Image/annex/6673de2e60b2091fb22ee52a.docx",
          "fileId": "6673de2e60b2091fb22ee52a.docx"
        }],
        isconfirm: "0",
        confirmtime: undefined,
        acceptIspass: undefined,
        rectificationOpinions: undefined,
        digitizationLevel: undefined,
        performanceAcceptanceReport: [],
        digitalEvaluationReport: [],
        remarks: undefined,
        status: undefined,
        creatoruserid: undefined,
        creatortime: undefined,
        lastmodifyuserid: undefined,
        lastmodifytime: undefined,
      },
      tableRequiredData: {},
      dataRule:
        {
          enterpriseName: [
            {
              required: true,
              message: '自动填充不可修改',
              trigger: 'blur'
            },
          ],
          enterpriseCreditCode: [
            {
              required: true,
              message: '自动填充不可修改',
              trigger: 'blur'
            },
          ],
          county: [
            {
              required: true,
              message: '请选择',
              trigger: 'change'
            },
          ],
          projectId: [
            {
              required: true,
              message: '自动填充不可修改',
              trigger: 'blur'
            },
          ],
          projectNames: [
            {
              required: true,
              message: '自动填充不可修改',
              trigger: 'blur'
            },
          ],
          digitalProjectContract: [
            {
              required: true,
              message: '请至少选择一个',
              trigger: 'change'
            },
          ],
          digitalProjectPlan: [
            {
              required: true,
              message: '请至少选择一个',
              trigger: 'change'
            },
          ],
          transactionRecords: [
            {
              required: true,
              message: '请至少选择一个',
              trigger: 'change'
            },
          ],
          scanningCopy: [
            {
              required: true,
              message: '请至少选择一个',
              trigger: 'change'
            },
          ],
          isconfirm: [
            {
              required: true,
              message: '请至少选择一个',
              trigger: 'change'
            },
          ],
          acceptIspass: [
            {
              required: true,
              message: '不能为空',
              trigger: 'change'
            },
          ],
          rectificationOpinions: [
            {
              required: true,
              message: '不能为空',
              trigger: 'change'
            },
          ],
          digitizationLevel: [
            {
              required: true,
              message: '请至少选择一个',
              trigger: 'change'
            },
          ],
          performanceAcceptanceReport: [
            {
              required: true,
              message: '不能为空',
              trigger: 'change'
            },
          ],
          digitalEvaluationReport: [
            {
              required: true,
              message: '不能为空',
              trigger: 'change'
            },
          ],
        },
      countyOptions: [{"fullName": "鼓楼区", "id": "鼓楼区"}, {"fullName": "台江区", "id": "台江区"}, {
        "fullName": "仓山区",
        "id": "仓山区"
      }, {"fullName": "马尾区", "id": "马尾区"}, {"fullName": "晋安区", "id": "晋安区"}, {
        "fullName": "长乐区",
        "id": "长乐区"
      }, {"fullName": "闽侯县", "id": "闽侯县"}, {"fullName": "连江县", "id": "连江县"}, {
        "fullName": "罗源县",
        "id": "罗源县"
      }, {"fullName": "闽清县", "id": "闽清县"}, {"fullName": "永泰县", "id": "永泰县"}, {
        "fullName": "福清市",
        "id": "福清市"
      }, {"fullName": "高新区", "id": "高新区"}],
      countyProps: {"label": "fullName", "value": "id"},
      isconfirmOptions: [{"fullName": "确认", "id": "1"}, {"fullName": "未确认", "id": "0"}],
      isconfirmProps: {"label": "fullName", "value": "id"},
      acceptIspassOptions: [{"fullName": "建议通过", "id": "1"}, {"fullName": "建议整改", "id": "0"}],
      acceptIspassProps: {"label": "fullName", "value": "id"},
      digitizationLevelOptions: [{"fullName": "无等级", "id": "0"}, {"fullName": "一级", "id": "1"}, {
        "fullName": "二级",
        "id": "2"
      }, {"fullName": "三级", "id": "3"}, {"fullName": "四级", "id": "4"}],
      digitizationLevelProps: {"label": "fullName", "value": "id"},
      statusOptions: [{"fullName": "已审核", "id": "2"}, {"fullName": "审核中", "id": "1"}, {"fullName": "等待提交", "id": "0"}],
      statusProps: {"label": "fullName", "value": "id"},
      childIndex: -1,
      isEdit: false,
      interfaceRes: {
        enterpriseName: [],
        enterpriseCreditCode: [],
        county: [],
        phone: [],
        projectId: [],
        projectNames: [],
        digitalProjectContract: [],
        digitalProjectPlan: [],
        transactionRecords: [],
        scanningCopy: [],
        isconfirm: [],
        confirmtime: [],
        acceptIspass: [],
        rectificationOpinions: [],
        digitizationLevel: [],
        performanceAcceptanceReport: [],
        digitalEvaluationReport: [],
        remarks: [],
        status: [],
        creatoruserid: [],
        creatortime: [],
        lastmodifyuserid: [],
        lastmodifytime: [],
      },
    }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  watch: {},
  created() {
    this.dataAll()
    this.initDefaultData()
    this.dataValueAll = JSON.parse(JSON.stringify(this.dataForm))
  },
  mounted() {
  },
  methods: {
    selectProjectDigitalBudget(id) {
      const url = `http://test-fzzxqy.demo-caii.com/cloud-api2/fzzxqyz/projectDigitalBudgetToCheck?checkId=${id}`
      axios.get(url).then(res => {
        this.projectDigitalBudgetList = res.data.data
        this.otherProjectDigitalBudgetList = res.data.data.filter(project => {
          return project.otherDigitalBudget.length > 0;
        });
      })
    },
    prev() {
      this.index--
      if (this.index === 0) {
        this.prevDis = true
      }
      this.nextDis = false
      for (let index = 0; index < this.allList.length; index++) {
        const element = this.allList[index];
        if (this.index == index) {
          this.getInfo(element.id)
        }
      }
    },
    next() {
      this.index++
      if (this.index === this.allList.length - 1) {
        this.nextDis = true
      }
      this.prevDis = false
      for (let index = 0; index < this.allList.length; index++) {
        const element = this.allList[index];
        if (this.index == index) {
          this.getInfo(element.id)
        }
      }
    },
    getInfo(id) {
      request({
        url: '/api/example/Fz_await_acceptance_enterprise/' + id,
        method: 'get'
      }).then(res => {
        this.dataInfo(res.data)
      });
    },
    changeData(model, index) {
      this.isEdit = false
      this.childIndex = index
      let modelAll = model.split("-");
      let faceMode = "";
      for (let i = 0; i < modelAll.length; i++) {
        faceMode += modelAll[i];
      }
      for (let key in this.interfaceRes) {
        if (key != faceMode) {
          let faceReList = this.interfaceRes[key]
          for (let i = 0; i < faceReList.length; i++) {
            if (faceReList[i].relationField == model) {
              let options = 'get' + key + 'Options';
              if (this[options]) {
                this[options]()
              }
              this.changeData(key, index)
            }
          }
        }
      }
    },
    changeDataFormData(type, data, model, index, defaultValue) {
      if (!this.isEdit) {
        if (type == 2) {
          for (let i = 0; i < this.dataForm[data].length; i++) {
            if (index == -1) {
              this.dataForm[data][i][model] = defaultValue
            } else if (index == i) {
              this.dataForm[data][i][model] = defaultValue
            }
          }
        } else {
          this.dataForm[data] = defaultValue
        }
      }
    },
    dataAll() {
    },
    goBack() {
      this.$emit('refresh')
    },
    clearData() {
      this.dataForm = JSON.parse(JSON.stringify(this.dataValueAll))
    },
    init(id, isDetail, allList) {
      this.selectProjectDigitalBudget(id);
      this.prevDis = false
      this.nextDis = false
      this.allList = allList || []
      if (allList.length) {
        this.index = this.allList.findIndex(item => item.id === id)
        if (this.index == 0) {
          this.prevDis = true
        }
        if (this.index == this.allList.length - 1) {
          this.nextDis = true
        }
      } else {
        this.prevDis = true
        this.nextDis = true
      }
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.loading = true
          request({
            url: '/api/example/Fz_await_acceptance_enterprise/' + this.dataForm.id,
            method: 'get'
          }).then(res => {
            this.dataInfo(res.data)
            this.loading = false
          });
        } else {
          this.clearData()
          this.initDefaultData()
        }
      });
      this.$store.commit('generator/UPDATE_RELATION_DATA', {})
    },
    //初始化默认数据
    initDefaultData() {

    },
    // 表单提交
    dataFormSubmit(type) {
      if (this.dataForm.acceptIspass === '0') {
        this.dataForm.remarks = '整改企业'
      }
      this.dataForm.creatoruserid = 'e' + this.dataForm.enterpriseCreditCode;
      this.dataFormSubmitType = type ? type : 0
      this.$refs['formRef'].validate((valid) => {
        if (valid) {
          this.$confirm('上传过后不能更改, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.request()
          })
        }
      })
    },
    request() {
      let _data = this.dataList()
      if (this.dataFormSubmitType == 2) {
        this.continueBtnLoading = true
      } else {
        this.btnLoading = true
      }
      if (!this.dataForm.id) {
        request({
          url: '/api/example/Fz_await_acceptance_enterprise',
          method: 'post',
          data: _data
        }).then((res) => {
          this.$message({
            message: res.msg,
            type: 'success',
            duration: 1000,
            onClose: () => {
              if (this.dataFormSubmitType == 2) {
                this.$nextTick(() => {
                  this.clearData()
                  this.initDefaultData()
                })
                this.continueBtnLoading = false
                return
              }
              this.visible = false
              this.btnLoading = false
              this.$emit('refresh', true)
            }
          })
        }).catch(() => {
          this.btnLoading = false
          this.continueBtnLoading = false
        })
      } else {
        request({
          url: '/api/example/Fz_await_acceptance_enterprise/' + this.dataForm.id,
          method: 'PUT',
          data: _data
        }).then((res) => {
          this.$message({
            message: res.msg,
            type: 'success',
            duration: 1000,
            onClose: () => {
              if (this.dataFormSubmitType == 2) return this.continueBtnLoading = false
              this.visible = false
              this.btnLoading = false
              this.$emit('refresh', true)
              //获取到该条数据的id去进行添加已验收数据及通过未通过的后续操作
              var id = res.data.id;
              var acceptIspass = res.data.acceptIspass;
              var eCode = res.data.enterpriseCreditCode;
              this.insertAcceptedData(eCode, id, acceptIspass);
            }
          })
        }).catch(() => {
          this.btnLoading = false
          this.continueBtnLoading = false
        })
      }
    },
    insertAcceptedData(eCode, id, acceptIspass) {
      console.log("eCode----"+JSON.stringify(eCode))
      console.log("id----"+JSON.stringify(id))
      console.log("acceptIspass----"+JSON.stringify(acceptIspass))
      //待验收后置操作,添加到已验收表中,根据验收状态去操作验收表及发送验收信息
      let url = `/api/system/DataInterface/573491797968292165/Actions/Preview`;
      let params = {
        "paramList": [
          {
            "id": "VkLuq92",
            "field": "eCode",
            "defaultValue": eCode ,
            "fieldName": "信用代码",
            "dataType": "varchar",
            "required": 0
          },
          {
            "id": "Gb5Xv92",
            "field": "id",
            "defaultValue": id,
            "fieldName": "验收id",
            "dataType": "varchar",
            "required": 0
          },
          {
            "id": "umXfQA2",
            "field": "acceptIspass",
            "defaultValue": acceptIspass,
            "fieldName": "第三方验收是否通过",
            "dataType": "varchar",
            "required": 0
          }
        ],
        "tenantId": "",
        "origin": "preview"
      };
      request({
        url: url,
        method: 'post',
        data: params
      }).then(res => {
        this.$message({
          message: '已添加至已验收列表中!',
          type: 'success'
        })
      })
    },
    openSelectDialog(key) {
      this.currTableConf = this.addTableConf[key]
      this.currVmodel = key
      this.selectDialogVisible = true
      this.$nextTick(() => {
        this.$refs.selectDialog.init()
      })
    },
    addForSelect(data) {
      for (let i = 0; i < data.length; i++) {
        let t = data[i]
        if (this['get' + this.currVmodel]) {
          this['get' + this.currVmodel](t)
        }
      }
    },
    dateTime(timeRule, timeType, timeTarget, timeValueData, dataValue) {
      let timeDataValue = null;
      let timeValue = Number(timeValueData)
      if (timeRule) {
        if (timeType == 1) {
          timeDataValue = timeValue
        } else if (timeType == 2) {
          timeDataValue = dataValue
        } else if (timeType == 3) {
          timeDataValue = new Date().getTime()
        } else if (timeType == 4) {
          let previousDate = '';
          if (timeTarget == 1 || timeTarget == 2) {
            previousDate = getDateDay(timeTarget, timeType, timeValue)
            timeDataValue = new Date(previousDate).getTime()
          } else if (timeTarget == 3) {
            previousDate = getBeforeData(timeValue)
            timeDataValue = new Date(previousDate).getTime()
          } else {
            timeDataValue = getBeforeTime(timeTarget, timeValue).getTime()
          }
        } else if (timeType == 5) {
          let previousDate = '';
          if (timeTarget == 1 || timeTarget == 2) {
            previousDate = getDateDay(timeTarget, timeType, timeValue)
            timeDataValue = new Date(previousDate).getTime()
          } else if (timeTarget == 3) {
            previousDate = getLaterData(timeValue)
            timeDataValue = new Date(previousDate).getTime()
          } else {
            timeDataValue = getLaterTime(timeTarget, timeValue).getTime()
          }
        }
      }
      return timeDataValue;
    },
    time(timeRule, timeType, timeTarget, timeValue, formatType, dataValue) {
      let format = formatType == 'HH:mm' ? 'HH:mm:00' : formatType
      let timeDataValue = null
      if (timeRule) {
        if (timeType == 1) {
          timeDataValue = timeValue || '00:00:00'
          if (timeDataValue.split(':').length == 3) {
            timeDataValue = timeDataValue
          } else {
            timeDataValue = timeDataValue + ':00'
          }
        } else if (timeType == 2) {
          timeDataValue = dataValue
        } else if (timeType == 3) {
          timeDataValue = this.jnpf.toDate(new Date(), format)
        } else if (timeType == 4) {
          let previousDate = '';
          previousDate = getBeforeTime(timeTarget, timeValue)
          timeDataValue = this.jnpf.toDate(previousDate, format)
        } else if (timeType == 5) {
          let previousDate = '';
          previousDate = getLaterTime(timeTarget, timeValue)
          timeDataValue = this.jnpf.toDate(previousDate, format)
        }
      }
      return timeDataValue;
    },
    dataList() {
      var _data = this.dataForm;
      return _data;
    },
    dataInfo(dataAll) {
      let _dataAll = dataAll
      this.dataForm = _dataAll
      this.isEdit = true
      this.dataAll()
      this.childIndex = -1
    },
  },
}

</script>
<style lang="scss" scoped>
.main .project-main {
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1) !important;
  border: 1px solid #EBEEF5;
  padding: 20px;
  border-radius: 5px;
}

::v-deep .el-textarea__inner {
  min-height: 100px !important;
}

::v-deep .el-input-number--medium {
  width: 100% !important;
}

.file-main {
  display: flex;
  flex-direction: row;

  label {
    color: #606266;
    font-size: 14px;
  }
}
</style>
